package com.tang.crm.controller;

import com.tang.crm.base.BaseController;
import com.tang.crm.dto.CustomerOrderDto;
import com.tang.crm.service.CustomerOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * 客户订单管理
 * @author SHIRELY阳
 */
@Controller
@RequestMapping("/order")
public class CustomerOrderController extends BaseController {

    @Autowired
    private CustomerOrderService customerOrderService;

    /**
     * 分页多条件查询客户订单列表
     * @param customerOrderDto
     * @return
     */
    @RequestMapping("/list")
    @ResponseBody
    public Map<String, Object> selectByParams(CustomerOrderDto customerOrderDto){
        return customerOrderService.selectByParams(customerOrderDto);
    }

    /**
     * 打开订单详情的页面
     * @param orderId
     * @param model
     * @return
     */
    @RequestMapping("/toOrderDetailPage")
    public String toOrderDetailPage(Integer orderId, Model model){
        // 通过订单ID查询对应的订单记录
        Map<String, Object> map = customerOrderService.selectOrderById(orderId);
        model.addAttribute("order", map);
        return "customer/customer_order_detail";
    }
}
